/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


import java.awt.*;
import java.applet.*;
import java.awt.geom.*;
import java.util.*;
import java.awt.Polygon;



/**
 *
 * @author shohdi
 */
public class RandomPolygons extends Applet {

  
   private int [] polygonX = {0,-10,-7,7,10};
   private int [] polygonY = {-10,-2,10,10,-2};
   Polygon poly = new Polygon(polygonX,polygonY,polygonX.length);
    
    
    public void init()
    {
      
        setSize(640,480);
        
        
       
        
        
    }
   
    
    public void paint(Graphics g)
    {
        
        
        Graphics2D g2d = (Graphics2D)g;
        
        AffineTransform identity  = new  AffineTransform();
        
        Rectangle2D rect = new Rectangle2D.Double(-1,-1,1,1);
        
        
        g2d.setTransform(identity);
        
        g2d.setColor(Color.BLACK);
        
        int width = getSize().width;
        
        int height = getSize().height;
        
        
        g2d.fill(new Rectangle(0,0,width,height));
        
        
        
        
        Random rand = new  Random();
        
        
        
        
        for (int n=0;n<300;n++)
        {
            g2d.setTransform(identity);
            g2d.translate(rand.nextInt()%width,rand.nextInt()%height );
            g2d.rotate(rand.nextDouble() * 360);
            g2d.scale(5 * rand.nextDouble(),5 * rand.nextDouble());
            
            g2d.setColor(new Color(rand.nextInt()));
            
            g2d.fill(poly);
            
                    
        }
        
        
        //setSize(640,480);
        //super.setSize(640,480);
        //width = getSize().width;
        //height = getSize().height;
               
        
        g2d.setTransform(identity);
        g2d.setFont(new Font("Tahoma",Font.BOLD,25));
        g2d.setColor(Color.WHITE);
        g2d.drawString("Width : " + width + " Hegiht : " + height, 20 , 20);
        
        
    }
    
    
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
       
    }
}





